<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE MagicHash #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE BangPatterns #-}</span><span>
</span><span id="line-4"></span><span>
</span><span id="line-5"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- Module      : Data.Text.Internal.Encoding.Utf16</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Copyright   : (c) 2008, 2009 Tom Harper,</span><span>
</span><span id="line-8"></span><span class="hs-comment">--               (c) 2009 Bryan O'Sullivan,</span><span>
</span><span id="line-9"></span><span class="hs-comment">--               (c) 2009 Duncan Coutts</span><span>
</span><span id="line-10"></span><span class="hs-comment">--</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- License     : BSD-style</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Maintainer  : bos@serpentine.com</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Stability   : experimental</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Portability : GHC</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- /Warning/: this is an internal module, and does not have a stable</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- API or name. Functions in this module may not check or enforce</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- preconditions expected by public modules. Use at your own risk!</span><span>
</span><span id="line-19"></span><span class="hs-comment">--</span><span>
</span><span id="line-20"></span><span class="hs-comment">-- Basic UTF-16 validation and character manipulation.</span><span>
</span><span id="line-21"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Text.Internal.Encoding.Utf16</span><span>
</span><span id="line-22"></span><span>    </span><span class="hs-special">(</span><span>
</span><span id="line-23"></span><span>      </span><span class="annot"><a href="Data.Text.Internal.Encoding.Utf16.html#chr2"><span class="hs-identifier">chr2</span></a></span><span>
</span><span id="line-24"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.Encoding.Utf16.html#validate1"><span class="hs-identifier">validate1</span></a></span><span>
</span><span id="line-25"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.Encoding.Utf16.html#validate2"><span class="hs-identifier">validate2</span></a></span><span>
</span><span id="line-26"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Exts.html#"><span class="hs-identifier">GHC.Exts</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#"><span class="hs-identifier">GHC.Word</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier">Word16</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-cpp">

#if !MIN_VERSION_base(4,16,0)
</span><span class="hs-comment">-- harmless to import, except for warnings that it is unused.</span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Internal.PrimCompat.html"><span class="hs-identifier">Data.Text.Internal.PrimCompat</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="Data.Text.Internal.PrimCompat.html#word16ToWord%23"><span class="hs-identifier">word16ToWord#</span></a></span><span> </span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-36"></span><span class="annot"><a href="Data.Text.Internal.Encoding.Utf16.html#chr2"><span class="hs-identifier hs-type">chr2</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span>
</span><span id="line-37"></span><span id="chr2"><span class="annot"><span class="annottext">chr2 :: Word16 -&gt; Word16 -&gt; Char
</span><a href="Data.Text.Internal.Encoding.Utf16.html#chr2"><span class="hs-identifier hs-var hs-var">chr2</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Word.html#W16%23"><span class="hs-identifier hs-type">W16#</span></a></span><span> </span><span id="local-6989586621679104330"><span class="annot"><span class="annottext">Word#
</span><a href="#local-6989586621679104330"><span class="hs-identifier hs-var">a#</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Word.html#W16%23"><span class="hs-identifier hs-type">W16#</span></a></span><span> </span><span id="local-6989586621679104329"><span class="annot"><span class="annottext">Word#
</span><a href="#local-6989586621679104329"><span class="hs-identifier hs-var">b#</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char# -&gt; Char
</span><a href="../../ghc-prim/src/GHC.Types.html#C%23"><span class="hs-identifier hs-var">C#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int# -&gt; Char#
</span><a href="../../ghc-prim/src/GHC.Prim.html#chr%23"><span class="hs-identifier hs-var">chr#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679104328"><span class="hs-identifier hs-var">upper#</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#%2B%23"><span class="hs-operator hs-var">+#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679104327"><span class="hs-identifier hs-var">lower#</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#%2B%23"><span class="hs-operator hs-var">+#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">0x10000#</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-39"></span><span>      </span><span class="hs-glyph">!</span><span id="local-6989586621679104326"><span class="annot"><span class="annottext">x# :: Int#
</span><a href="#local-6989586621679104326"><span class="hs-identifier hs-var hs-var">x#</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#word2Int%23"><span class="hs-identifier hs-var">word2Int#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word# -&gt; Word#
</span><a href="Data.Text.Internal.PrimCompat.html#word16ToWord%23"><span class="hs-identifier hs-var">word16ToWord#</span></a></span><span> </span><span class="annot"><span class="annottext">Word#
</span><a href="#local-6989586621679104330"><span class="hs-identifier hs-var">a#</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-40"></span><span>      </span><span class="hs-glyph">!</span><span id="local-6989586621679104325"><span class="annot"><span class="annottext">y# :: Int#
</span><a href="#local-6989586621679104325"><span class="hs-identifier hs-var hs-var">y#</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#word2Int%23"><span class="hs-identifier hs-var">word2Int#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word# -&gt; Word#
</span><a href="Data.Text.Internal.PrimCompat.html#word16ToWord%23"><span class="hs-identifier hs-var">word16ToWord#</span></a></span><span> </span><span class="annot"><span class="annottext">Word#
</span><a href="#local-6989586621679104329"><span class="hs-identifier hs-var">b#</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-41"></span><span>      </span><span class="hs-glyph">!</span><span id="local-6989586621679104328"><span class="annot"><span class="annottext">upper# :: Int#
</span><a href="#local-6989586621679104328"><span class="hs-identifier hs-var hs-var">upper#</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#uncheckedIShiftL%23"><span class="hs-identifier hs-var">uncheckedIShiftL#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679104326"><span class="hs-identifier hs-var">x#</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#-%23"><span class="hs-operator hs-var">-#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">0xD800#</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">10#</span></span><span>
</span><span id="line-42"></span><span>      </span><span class="hs-glyph">!</span><span id="local-6989586621679104327"><span class="annot"><span class="annottext">lower# :: Int#
</span><a href="#local-6989586621679104327"><span class="hs-identifier hs-var hs-var">lower#</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int#
</span><a href="#local-6989586621679104325"><span class="hs-identifier hs-var">y#</span></a></span><span> </span><span class="annot"><span class="annottext">Int# -&gt; Int# -&gt; Int#
</span><a href="../../ghc-prim/src/GHC.Prim.html#-%23"><span class="hs-operator hs-var">-#</span></a></span><span> </span><span class="annot"><span class="annottext">Int#
</span><span class="hs-number">0xDC00#</span></span><span>
</span><span id="line-43"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Internal.Encoding.Utf16.html#chr2"><span class="hs-pragma hs-type">chr2</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-44"></span><span>
</span><span id="line-45"></span><span class="annot"><a href="Data.Text.Internal.Encoding.Utf16.html#validate1"><span class="hs-identifier hs-type">validate1</span></a></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-46"></span><span id="validate1"><span class="annot"><span class="annottext">validate1 :: Word16 -&gt; Bool
</span><a href="Data.Text.Internal.Encoding.Utf16.html#validate1"><span class="hs-identifier hs-var hs-var">validate1</span></a></span></span><span> </span><span id="local-6989586621679104324"><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679104324"><span class="hs-identifier hs-var">x1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679104324"><span class="hs-identifier hs-var">x1</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C"><span class="hs-operator hs-var">&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0xD800</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679104324"><span class="hs-identifier hs-var">x1</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E"><span class="hs-operator hs-var">&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0xDFFF</span></span><span>
</span><span id="line-47"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Internal.Encoding.Utf16.html#validate1"><span class="hs-pragma hs-type">validate1</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span class="annot"><a href="Data.Text.Internal.Encoding.Utf16.html#validate2"><span class="hs-identifier hs-type">validate2</span></a></span><span>       </span><span class="hs-glyph">::</span><span>  </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-50"></span><span id="validate2"><span class="annot"><span class="annottext">validate2 :: Word16 -&gt; Word16 -&gt; Bool
</span><a href="Data.Text.Internal.Encoding.Utf16.html#validate2"><span class="hs-identifier hs-var hs-var">validate2</span></a></span></span><span> </span><span id="local-6989586621679104320"><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679104320"><span class="hs-identifier hs-var">x1</span></a></span></span><span> </span><span id="local-6989586621679104319"><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679104319"><span class="hs-identifier hs-var">x2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679104320"><span class="hs-identifier hs-var">x1</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0xD800</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679104320"><span class="hs-identifier hs-var">x1</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0xDBFF</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span>
</span><span id="line-51"></span><span>                  </span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679104319"><span class="hs-identifier hs-var">x2</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0xDC00</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679104319"><span class="hs-identifier hs-var">x2</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0xDFFF</span></span><span>
</span><span id="line-52"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Internal.Encoding.Utf16.html#validate2"><span class="hs-pragma hs-type">validate2</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-53"></span></pre></body></html>